<%-- 
    Document   : ApproveOrder
    Created on : Apr 9, 2014, 5:01:28 PM
    Author     : Mukesh
--%>

<!doctype html>
<%
    try {
        if (session.getAttribute("uid") != null) {
            if (session.getAttribute("Approve_Order").toString().equals("1")) {
%>
<%String to = "", status = "", msg = "";%>
<html lang="en">

    <head>
        <meta charset="utf-8">
        <title>Ramgovind Automated System</title>

        <link rel="stylesheet" href="/RIT/css/bootstrap.css">
        <link rel="stylesheet" href="/RIT/css/bootstrap-responsive.css">
        <link rel="stylesheet" href="/RIT/css/jquery.fancybox.css">
        <link rel="stylesheet" href="/RIT/css/uniform.default.css">
        <link rel="stylesheet" href="/RIT/css/bootstrap.datepicker.css">
        <link rel="stylesheet" href="/RIT/css/jquery.cleditor.css">
        <link rel="stylesheet" href="/RIT/css/jquery.plupload.queue.css">
        <link rel="stylesheet" href="/RIT/css/jquery.tagsinput.css">
        <link rel="stylesheet" href="/RIT/css/jquery.ui.plupload.css">
        <link rel="stylesheet" href="/RIT/js/tableTools/css/TableTools.css">
        <link rel="stylesheet" href="/RIT/css/chosen.css">
        <link rel="stylesheet" href="/RIT/css/chosen.css">
        <link rel="stylesheet" href="/RIT/css/style.css">
        <link rel="stylesheet" href="/RIT/css/iconfont.css">
        <script type="text/javascript">
            function loadOrder()
            {
                document.getElementById('ILoader').setAttribute("style", "visibility: visible;width: 250px;height: 250px;position: absolute;top: 50%;left:50%;margin-top: -80px;margin-left: -40px;background:url(/RIT/img/loader.gif) no-repeat;z-index: 667999;background-size:200px 200px;");
                var table = document.getElementById('ct');
                for (var i = table.rows.length - 1; i > 0; i--)
                {
                    table.deleteRow(i);
                }
                var xmlhttp;
                if (window.XMLHttpRequest)
                {
                    xmlhttp = new XMLHttpRequest();
                }
                else
                {
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange = function()
                {
                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                    {
                        document.getElementById('ctbody').innerHTML = xmlhttp.responseText;
                        document.getElementById('ILoader').removeAttribute("style");
                        loadApprovedOrder();
                    }
                }
                xmlhttp.open("POST", "/RIT/ApproveOrderList", true);
                xmlhttp.send();
            }
            function loadApprovedOrder()
            {
                var table = document.getElementById('ct1');
                for (var i = table.rows.length - 1; i > 0; i--)
                {
                    table.deleteRow(i);
                }
                var xmlhttp;
                if (window.XMLHttpRequest)
                {
                    xmlhttp = new XMLHttpRequest();
                }
                else
                {
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange = function()
                {
                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                    {
                        document.getElementById('tbody').innerHTML = xmlhttp.responseText;
                    }
                }
                xmlhttp.open("POST", "/RIT/ApprovedOrderList", true);
                xmlhttp.send();
            }

            function approveOrder(i, action)
            {
                var xmlhttp;
                if (window.XMLHttpRequest)
                {
                    xmlhttp = new XMLHttpRequest();
                }
                else
                {
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange = function()
                {
                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                    {
                        var temp = xmlhttp.responseText;
                        var table = document.getElementById(i);
                        for (var j = 9; j >= 0; j--)
                        {
                            table.deleteCell(j);
                            document.getElementById('myModal').className = 'modal hide';
                            document.getElementById('delthis').value = '';
                            loadApprovedOrder();
                        }
                    }
                }
                xmlhttp.open("POST", "/RIT/ApproveDisOrder?id="+i+"&action="+action, false);
                xmlhttp.send();
            }
        </script>
    </head>
    <body onload="loadOrder()">					
        <div id="ILoader"></div>
        <%@include file="/topheader.html" %>
        <%@include file="/servicesheader.html" %>
        <div class="main">
            <div class="container-fluid">
                <%@include file="/Services/Inventory/inventorysidenav.jsp" %>
                <div class="content">
                    <%if (session.getAttribute("status") != null) {
                            status = session.getAttribute("status").toString();
                            msg = session.getAttribute("msg").toString();
                    %>
                    <div class="alert alert-info alert-block">
                        <a class="close" data-dismiss="alert" href="#"><img src="/RIT/img/mclose.png"></a>
                        <h4 class="alert-heading"> <%=status%></h4>
                        <%=msg%>
                    </div>
                    <%session.removeAttribute("status");
                            session.removeAttribute("msg");
                        }%>
                    <div class="row-fluid">
                        <div class="box">
                            <div class="modal hide" id="myModal">
                                <div class="modal-header">
                                    <button type="button" class="close" onclick="document.getElementById('myModal').className = 'modal hide'"><img src="/RIT/img/mclose.png"></button>
                                    <h3 style=" color: red;">Warning...</h3>
                                </div>
                                <div class="modal-body">
                                    <p>Are you sure to delete?</p>
                                </div>
                                <div class="modal-footer">
                                    <input type="hidden" value="" id="delthis">
                                    <a href="#" class="btn btn-primary" onclick="deleteOrder()"> Ok </a>
                                </div>
                            </div>
                            <div class="box-head tabs">
                                <h3>Purchase Order List</h3>
                                <div style="float:right;display:flex">
                                    <div class="input-prepend input-append">
                                        <input type="text" class="input-square" placeholder="Search here..." name="" id="" style="width: 100px;"><span class="add-on"><a href="#" class="ficon-search"></a></span>
                                    </div>

                                </div>
                            </div>
                            <div class="box-content box-nomargin">
                                <table class='table table-striped dataTable-noheader dataTable-nofooter table-bordered' id="ct">
                                    <thead>
                                        <tr>
                                            <th>Product Name</th>
                                            <th>Quantity</th>
                                            <th>Vendor</th>
                                            <th>Price</th>
                                            <th>Tax</th>
                                            <th>Total</th>
                                            <th>Order Date</th>
                                            <th>Order By</th>
                                            <th>Description</th>
                                            <th>Action</th>
                                        </tr>
                                    </thead>
                                    <tbody id="ctbody">

                                    </tbody>
                                </table>
                            </div>
                        </div>
                        
                        
                        <div class="box">
                            
                            <div class="box-head tabs">
                                <h3>Approved Order</h3>
                                
                            </div>
                            <div class="box-content box-nomargin">
                                <table class='table table-striped dataTable-noheader dataTable-nofooter table-bordered' id="ct1">
                                    <thead>
                                        <tr>
                                            <th>Product Name</th>
                                            <th>Quantity</th>
                                            <th>Vendor</th>
                                            <th>Price</th>
                                            <th>Tax</th>
                                            <th>Total</th>
                                            <th>Order Date</th>
                                            <th>Order By</th>
                                            <th>Approval No.</th>
                                            <th>Description</th>
                                            <th>Action</th>
                                        </tr>
                                    </thead>
                                    <tbody id="tbody">

                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>	
            </div>
        </div>
    </div>	
    <script src="/RIT/js/jquery.js"></script>
    <script src="/RIT/js/less.js"></script>
    <script src="/RIT/js/bootstrap.min.js"></script>
    <script src="/RIT/js/jquery.uniform.min.js"></script>
    <script src="/RIT/js/bootstrap.timepicker.js"></script>
    <script src="/RIT/js/bootstrap.datepicker.js"></script>
    <script src="/RIT/js/chosen.jquery.min.js"></script>
    <script src="/RIT/js/jquery.fancybox.js"></script>
    <script src="/RIT/js/plupload/plupload.full.js"></script>
    <script src="/RIT/js/plupload/jquery.plupload.queue/jquery.plupload.queue.js"></script>
    <script src="/RIT/js/jquery.cleditor.min.js"></script>
    <script src="/RIT/js/jquery.inputmask.min.js"></script>
    <script src="/RIT/js/jquery.tagsinput.min.js"></script>
    <script src="/RIT/js/jquery.mousewheel.js"></script>
    <script src="/RIT/js/jquery.dataTables.min.js"></script>
    <script src="/RIT/js/jquery.dataTables.bootstrap.js"></script>
    <script src="/RIT/js/jquery.textareaCounter.plugin.js"></script>
    <script src="/RIT/js/ui.spinner.js"></script>
    <script src="/RIT/js/jquery.cookie.js"></script>
    <script src="/RIT/js/tableTools/js/TableTools.min.js"></script>
    <script src="/RIT/js/custom.js"></script><script src="js/demo.js"></script>
    <script src="/RIT/js/iconfont.js"></script>
</body>

</html>

<%} else {
%>
<script type="text/javascript">
                                        alert("You Are Not Authorised");
                                        window.history.back();
</script>
<%             }
        } else {
            request.setAttribute("msg", "You Are Not Authorised! Please Contact to System Administrator!");
            request.setAttribute("value", "0");
            getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
        }
    } catch (Exception e) {
        request.setAttribute("msg", "Please Contact to System Administrator!");
        request.setAttribute("value", "0");
        getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
    }
%>

